package com.cangxuan.manage.service.impl;

import com.cangxuan.manage.bean.Page;
import com.cangxuan.manage.dao.IRegistrationDao;
import com.cangxuan.manage.dao.IUserGoodsDao;
import com.cangxuan.manage.entity.Registration;
import com.cangxuan.manage.entity.UserAmountRecord;
import com.cangxuan.manage.exception.ServiceException;
import com.cangxuan.manage.service.IRegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLIntegrityConstraintViolationException;
import java.util.List;
@Service
public class IRegistrationImpl implements IRegistrationService {
    IRegistrationDao iRegistrationDao;
    @Autowired
    public void setiRegistrationDao(IRegistrationDao iRegistrationDao) {
        this.iRegistrationDao = iRegistrationDao;
    }



    IUserGoodsDao iUserGoodsDao;
    @Autowired
    public void setiUserGoodsDao(IUserGoodsDao iUserGoodsDao) {
        this.iUserGoodsDao = iUserGoodsDao;
    }

    @Override
    public List<Registration> list(String name, Integer userId) {
        return iRegistrationDao.select(name,userId);
    }

    @Override
    public Page<Registration> page(int pageIndex, int pageSize, String name,Integer userId) {
        Page<Registration>  registrationPage=new Page<>(pageIndex,pageSize);
        registrationPage.setRecords(iRegistrationDao.selectById(pageIndex, pageSize,name,userId));
        registrationPage.setTotal(iRegistrationDao.selectCount(name,userId));
        return registrationPage;
    }

    @Override
    public boolean save(int id ) {
        return iRegistrationDao.update(id)>0;
    }


}
